import axios from "axios";
axios.defaults.baseURL = 'https://www.liulongbin.top:8888/api/private/v1/';
axios.defaults.timeout = 5000;
//axios请求拦截器
axios.interceptors.request.use((config)=>{
    // NProgress.start();
    config.headers.Authorization = window.sessionStorage.getItem("token");
    return config;
});
axios.interceptors.response.use((config)=>{
    // NProgress.done();
/*    let {data: {meta, data}} = config;
    console.log("response-------->",data);

    switch (meta.status){
        case 200:
        case 201:
        case 204:
            data && data.token && window.sessionStorage.setItem("token", data.token);
            return Promise.resolve(data);
        default:
            return Promise.reject(meta.msg);
    }*/
    return config;
});


export default {
    //登录
    login(loginForm){
        return axios.post("login", loginForm)
    },
    //获取首页数据
    getHomeData(loginForm, page){
        return axios.get("getHomeData?page=" + page, {params:loginForm})
    }
}